package controller;

import entity.SysUser;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;


/**
 * HelloController
 *
 * @author boy
 * @since 2023/10/23
 */
@Controller
@RequestMapping(value = "/hello ")
public class HelloController {
Logger logger=Logger.getLogger(HelloController.class);
/*    @RequestMapping(value = "/hello2")
    public String hello2()throws Exception{
       System.out.println("Spring MVC 框架搭建成功");
       return "hello2";
   }
   @RequestMapping(value = "/hello2")
    public String hello2()throws Exception{
       logger.info("hello控制器下的另一个接口");
       return "hello2";
   } */
    @RequestMapping("/hello2")
    public String hello2(Model model,@RequestParam String realName) throws Exception{
        logger.info("你好【"+realName+"】欢迎来到springMvc课堂");
      model.addAttribute("realName",realName);
      model.addAttribute(realName);
        SysUser sysUser=new SysUser();
        sysUser.setRealName(realName);
      return "hello";
    }
    @RequestMapping("/hello3")
    public String hello2(Map<String,Object>map, @RequestParam String realName) throws Exception{
        logger.info("你好【"+realName+"】欢迎来到springMvc课堂");
       map.put("realName",realName);
        return "hello";
    }
}
